package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * Created with IntelliJ IDEA.
 * User: DK
 * Date: 9/24/13
 * Time: 6:31 PM
 * To change this template use File | Settings | File Templates.
 */
public class MovieInventory implements Inventory
{
    private ArrayList<Movie> movies;

    public MovieInventory(ArrayList<Movie> movies) {
        this.movies = movies;
    }

    public MovieInventory() {
        movies = new ArrayList<Movie>();
        movies.add(new Movie("Sholay",1975,"Ramesh Sippy","N/A"));
        movies.add(new Movie("Kanchori",1960,"XYZ","10"));
        movies.add(new Movie("Powell",2011,"Ramesh Sip1y","5"));
    }

    @Override
    public int numOfItemsInInventory() {
        return movies.size();
    }

    @Override
    public int typeOfInventory() {
        return Inventory.MOVIE_INVENTORY;
    }

    @Override
    public Iterator returnIterator() {
        return movies.iterator();
    }

    @Override
    public String list() {
        String result = "";
        Iterator iteratorOverBooks = movies.iterator();

        while(iteratorOverBooks.hasNext())
        {
            Movie movie = (Movie)iteratorOverBooks.next();
            result = result + movie.display();
        }

        return result;
    }

    @Override
    public boolean reserveAnItem(String id) {
        throw new UnsupportedOperationException("Movies cannot be reserved");
    }
}
